﻿using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;

namespace XZTZ.UMP.WEB.Data.Migrations
{
    public partial class lcffirst : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "AspNetRoles",
                columns: table => new
                {
                    Id = table.Column<string>(nullable: false),
                    Name = table.Column<string>(maxLength: 256, nullable: true),
                    NormalizedName = table.Column<string>(maxLength: 256, nullable: true),
                    ConcurrencyStamp = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AspNetRoles", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "AspNetUsers",
                columns: table => new
                {
                    Id = table.Column<string>(nullable: false),
                    UserName = table.Column<string>(maxLength: 256, nullable: true),
                    NormalizedUserName = table.Column<string>(maxLength: 256, nullable: true),
                    Email = table.Column<string>(maxLength: 256, nullable: true),
                    NormalizedEmail = table.Column<string>(maxLength: 256, nullable: true),
                    EmailConfirmed = table.Column<bool>(nullable: false),
                    PasswordHash = table.Column<string>(nullable: true),
                    SecurityStamp = table.Column<string>(nullable: true),
                    ConcurrencyStamp = table.Column<string>(nullable: true),
                    PhoneNumber = table.Column<string>(nullable: true),
                    PhoneNumberConfirmed = table.Column<bool>(nullable: false),
                    TwoFactorEnabled = table.Column<bool>(nullable: false),
                    LockoutEnd = table.Column<DateTimeOffset>(nullable: true),
                    LockoutEnabled = table.Column<bool>(nullable: false),
                    AccessFailedCount = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AspNetUsers", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "Base_AddressBook",
                columns: table => new
                {
                    guidABID = table.Column<Guid>(nullable: false),
                    strABName = table.Column<string>(nullable: true),
                    dtmOperateDate = table.Column<DateTime>(nullable: false),
                    strNote = table.Column<string>(nullable: true),
                    blnTabooFlag = table.Column<bool>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Base_AddressBook", x => x.guidABID);
                });

            migrationBuilder.CreateTable(
                name: "Base_BillProperty",
                columns: table => new
                {
                    StrPropertyId = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    StrPropertyName = table.Column<string>(nullable: true),
                    DtmOperateDate = table.Column<DateTime>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Base_BillProperty", x => x.StrPropertyId);
                });

            migrationBuilder.CreateTable(
                name: "Base_BillVision",
                columns: table => new
                {
                    GuidBillVisionId = table.Column<Guid>(nullable: false),
                    StrVisionName = table.Column<string>(maxLength: 50, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Base_BillVision", x => x.GuidBillVisionId);
                });

            migrationBuilder.CreateTable(
                name: "Base_CompanyType",
                columns: table => new
                {
                    guidCompanyTypeID = table.Column<Guid>(nullable: false),
                    strTypeCode = table.Column<string>(maxLength: 2, nullable: false),
                    strTypeName = table.Column<string>(maxLength: 20, nullable: false),
                    dtmOperateDate = table.Column<DateTime>(nullable: false),
                    blnTabooFlag = table.Column<bool>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Base_CompanyType", x => x.guidCompanyTypeID);
                });

            migrationBuilder.CreateTable(
                name: "Bid_ProjectInfo",
                columns: table => new
                {
                    ProjectID = table.Column<Guid>(nullable: false),
                    AreaInfo = table.Column<string>(nullable: true),
                    BeginDate = table.Column<DateTime>(nullable: false),
                    BeginStake = table.Column<string>(nullable: true),
                    BillVision = table.Column<Guid>(nullable: false),
                    BredgeNum = table.Column<string>(nullable: true),
                    ConfiremedMonth = table.Column<decimal>(nullable: false),
                    ConfirmedYear = table.Column<decimal>(nullable: false),
                    ConstructNo = table.Column<string>(nullable: true),
                    CulvertLen = table.Column<string>(nullable: true),
                    DocHttpURLAddress = table.Column<string>(nullable: true),
                    EndDate = table.Column<DateTime>(nullable: false),
                    EndStake = table.Column<string>(nullable: true),
                    FactInvest = table.Column<decimal>(nullable: false),
                    FactLength = table.Column<decimal>(nullable: false),
                    FlowVision = table.Column<Guid>(nullable: false),
                    IsOut = table.Column<bool>(nullable: false),
                    IsSubmited = table.Column<bool>(nullable: false),
                    MasterCompany = table.Column<string>(nullable: true),
                    Note = table.Column<string>(nullable: true),
                    OperateDate = table.Column<DateTime>(nullable: false),
                    Operator = table.Column<string>(nullable: true),
                    PlanInvest = table.Column<decimal>(nullable: false),
                    PlanLength = table.Column<decimal>(nullable: false),
                    PrimaryNo = table.Column<string>(nullable: true),
                    ProjectName = table.Column<string>(nullable: true),
                    ReplayBudgetary = table.Column<decimal>(nullable: false),
                    ReplaySchematic = table.Column<decimal>(nullable: false),
                    ReportVision = table.Column<Guid>(nullable: false),
                    RootDirAddress = table.Column<string>(nullable: true),
                    ShortNameCH = table.Column<string>(nullable: true),
                    ShortNameCN = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Bid_ProjectInfo", x => x.ProjectID);
                });

            migrationBuilder.CreateTable(
                name: "AspNetRoleClaims",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    RoleId = table.Column<string>(nullable: false),
                    ClaimType = table.Column<string>(nullable: true),
                    ClaimValue = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AspNetRoleClaims", x => x.Id);
                    table.ForeignKey(
                        name: "FK_AspNetRoleClaims_AspNetRoles_RoleId",
                        column: x => x.RoleId,
                        principalTable: "AspNetRoles",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "AspNetUserClaims",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    UserId = table.Column<string>(nullable: false),
                    ClaimType = table.Column<string>(nullable: true),
                    ClaimValue = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AspNetUserClaims", x => x.Id);
                    table.ForeignKey(
                        name: "FK_AspNetUserClaims_AspNetUsers_UserId",
                        column: x => x.UserId,
                        principalTable: "AspNetUsers",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "AspNetUserLogins",
                columns: table => new
                {
                    LoginProvider = table.Column<string>(maxLength: 128, nullable: false),
                    ProviderKey = table.Column<string>(maxLength: 128, nullable: false),
                    ProviderDisplayName = table.Column<string>(nullable: true),
                    UserId = table.Column<string>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AspNetUserLogins", x => new { x.LoginProvider, x.ProviderKey });
                    table.ForeignKey(
                        name: "FK_AspNetUserLogins_AspNetUsers_UserId",
                        column: x => x.UserId,
                        principalTable: "AspNetUsers",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "AspNetUserRoles",
                columns: table => new
                {
                    UserId = table.Column<string>(nullable: false),
                    RoleId = table.Column<string>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AspNetUserRoles", x => new { x.UserId, x.RoleId });
                    table.ForeignKey(
                        name: "FK_AspNetUserRoles_AspNetRoles_RoleId",
                        column: x => x.RoleId,
                        principalTable: "AspNetRoles",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_AspNetUserRoles_AspNetUsers_UserId",
                        column: x => x.UserId,
                        principalTable: "AspNetUsers",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "AspNetUserTokens",
                columns: table => new
                {
                    UserId = table.Column<string>(nullable: false),
                    LoginProvider = table.Column<string>(maxLength: 128, nullable: false),
                    Name = table.Column<string>(maxLength: 128, nullable: false),
                    Value = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AspNetUserTokens", x => new { x.UserId, x.LoginProvider, x.Name });
                    table.ForeignKey(
                        name: "FK_AspNetUserTokens_AspNetUsers_UserId",
                        column: x => x.UserId,
                        principalTable: "AspNetUsers",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "Base_AddressBookJoinUser ",
                columns: table => new
                {
                    guidABJoinUserID = table.Column<Guid>(nullable: false),
                    guidABID = table.Column<Guid>(nullable: false),
                    strUserCode = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Base_AddressBookJoinUser ", x => x.guidABJoinUserID);
                    table.ForeignKey(
                        name: "FK_Base_AddressBookJoinUser _Base_AddressBook_guidABID",
                        column: x => x.guidABID,
                        principalTable: "Base_AddressBook",
                        principalColumn: "guidABID",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "Base_BillTemplet",
                columns: table => new
                {
                    GuidBillId = table.Column<Guid>(nullable: false),
                    GuidParentId = table.Column<Guid>(nullable: false),
                    GuidBillVisionId = table.Column<Guid>(nullable: false),
                    StrType = table.Column<string>(nullable: true),
                    StrSubSortId = table.Column<string>(nullable: true),
                    StrLevelCode = table.Column<string>(nullable: true),
                    StrBillCode = table.Column<string>(nullable: true),
                    StrBillName = table.Column<string>(nullable: true),
                    StrUnit = table.Column<string>(nullable: true),
                    StrComputeType = table.Column<string>(nullable: true),
                    GuidAssociateBillId = table.Column<Guid>(nullable: true),
                    BlnIsExceed = table.Column<bool>(nullable: false),
                    StrParentShortName = table.Column<string>(nullable: true),
                    StrPropertyId = table.Column<int>(nullable: false),
                    IntIndexNo = table.Column<int>(nullable: false),
                    DtmOperateDate = table.Column<DateTime>(nullable: false),
                    BlnTabooFlag = table.Column<bool>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Base_BillTemplet", x => x.GuidBillId);
                    table.ForeignKey(
                        name: "FK_Base_BillTemplet_Base_BillVision_GuidBillVisionId",
                        column: x => x.GuidBillVisionId,
                        principalTable: "Base_BillVision",
                        principalColumn: "GuidBillVisionId",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_Base_BillTemplet_Base_BillProperty_StrPropertyId",
                        column: x => x.StrPropertyId,
                        principalTable: "Base_BillProperty",
                        principalColumn: "StrPropertyId",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "Base_CompanyInfo",
                columns: table => new
                {
                    guidCompanyID = table.Column<Guid>(nullable: false),
                    guidCompanyTypeID = table.Column<Guid>(nullable: false),
                    strCompanyName = table.Column<string>(nullable: true),
                    strShortName = table.Column<string>(nullable: true),
                    strCommissary = table.Column<string>(nullable: true),
                    strPhone = table.Column<string>(nullable: true),
                    strFax = table.Column<string>(nullable: true),
                    dtmOperateDate = table.Column<DateTime>(nullable: false),
                    strNote = table.Column<string>(nullable: true),
                    blnTabooFlag = table.Column<bool>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Base_CompanyInfo", x => x.guidCompanyID);
                    table.ForeignKey(
                        name: "FK_Base_CompanyInfo_Base_CompanyType_guidCompanyTypeID",
                        column: x => x.guidCompanyTypeID,
                        principalTable: "Base_CompanyType",
                        principalColumn: "guidCompanyTypeID",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "Base_DeparmentInfo",
                columns: table => new
                {
                    guidDepartmentID = table.Column<Guid>(nullable: false),
                    guidCompanyID = table.Column<Guid>(nullable: false),
                    strDepartmentName = table.Column<string>(nullable: true),
                    strEstablishment = table.Column<string>(nullable: true),
                    strGovernor = table.Column<string>(nullable: true),
                    strPhone = table.Column<string>(nullable: true),
                    strFax = table.Column<string>(nullable: true),
                    strLinkMan = table.Column<string>(nullable: true),
                    dtmOperateDate = table.Column<DateTime>(nullable: false),
                    strNote = table.Column<string>(nullable: true),
                    blnTabooFlag = table.Column<bool>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Base_DeparmentInfo", x => x.guidDepartmentID);
                    table.ForeignKey(
                        name: "FK_Base_DeparmentInfo_Base_CompanyInfo_guidCompanyID",
                        column: x => x.guidCompanyID,
                        principalTable: "Base_CompanyInfo",
                        principalColumn: "guidCompanyID",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_AspNetRoleClaims_RoleId",
                table: "AspNetRoleClaims",
                column: "RoleId");

            migrationBuilder.CreateIndex(
                name: "RoleNameIndex",
                table: "AspNetRoles",
                column: "NormalizedName",
                unique: true,
                filter: "[NormalizedName] IS NOT NULL");

            migrationBuilder.CreateIndex(
                name: "IX_AspNetUserClaims_UserId",
                table: "AspNetUserClaims",
                column: "UserId");

            migrationBuilder.CreateIndex(
                name: "IX_AspNetUserLogins_UserId",
                table: "AspNetUserLogins",
                column: "UserId");

            migrationBuilder.CreateIndex(
                name: "IX_AspNetUserRoles_RoleId",
                table: "AspNetUserRoles",
                column: "RoleId");

            migrationBuilder.CreateIndex(
                name: "EmailIndex",
                table: "AspNetUsers",
                column: "NormalizedEmail");

            migrationBuilder.CreateIndex(
                name: "UserNameIndex",
                table: "AspNetUsers",
                column: "NormalizedUserName",
                unique: true,
                filter: "[NormalizedUserName] IS NOT NULL");

            migrationBuilder.CreateIndex(
                name: "IX_Base_AddressBookJoinUser _guidABID",
                table: "Base_AddressBookJoinUser ",
                column: "guidABID");

            migrationBuilder.CreateIndex(
                name: "IX_Base_BillTemplet_GuidBillVisionId",
                table: "Base_BillTemplet",
                column: "GuidBillVisionId");

            migrationBuilder.CreateIndex(
                name: "IX_Base_BillTemplet_StrPropertyId",
                table: "Base_BillTemplet",
                column: "StrPropertyId");

            migrationBuilder.CreateIndex(
                name: "IX_Base_CompanyInfo_guidCompanyTypeID",
                table: "Base_CompanyInfo",
                column: "guidCompanyTypeID");

            migrationBuilder.CreateIndex(
                name: "IX_Base_DeparmentInfo_guidCompanyID",
                table: "Base_DeparmentInfo",
                column: "guidCompanyID");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "AspNetRoleClaims");

            migrationBuilder.DropTable(
                name: "AspNetUserClaims");

            migrationBuilder.DropTable(
                name: "AspNetUserLogins");

            migrationBuilder.DropTable(
                name: "AspNetUserRoles");

            migrationBuilder.DropTable(
                name: "AspNetUserTokens");

            migrationBuilder.DropTable(
                name: "Base_AddressBookJoinUser ");

            migrationBuilder.DropTable(
                name: "Base_BillTemplet");

            migrationBuilder.DropTable(
                name: "Base_DeparmentInfo");

            migrationBuilder.DropTable(
                name: "Bid_ProjectInfo");

            migrationBuilder.DropTable(
                name: "AspNetRoles");

            migrationBuilder.DropTable(
                name: "AspNetUsers");

            migrationBuilder.DropTable(
                name: "Base_AddressBook");

            migrationBuilder.DropTable(
                name: "Base_BillVision");

            migrationBuilder.DropTable(
                name: "Base_BillProperty");

            migrationBuilder.DropTable(
                name: "Base_CompanyInfo");

            migrationBuilder.DropTable(
                name: "Base_CompanyType");
        }
    }
}
